﻿@model Tuple<deviceManage.Models.Device, deviceManage.Models.ScrapLog>

<style>
    .layui-layout-body{
        overflow:auto;
    }
    .layadmin-carousel .layui-carousel-ind{
        position: absolute;
        top: -43px;
        text-align: right;
        width: 100px;
        margin-left: 110px;
    }

    .layui-carousel .layui-row {
        text-align: center;
    }

     .layui-carousel .layui-row img {
           width: 240px;
           height: 178px;
     }

    .layui-form-label {
        text-align: right;
        padding-top: 5px;
        padding-right: 1px;
        width: 100px;
        padding-left:0;
    }
    .layui-form-label.w80{
        width:80px;
    }

    .layui-form-label-value {
       text-align: left;
       width: 120px;
       padding-left: 0;
    }

    .layui-form-item .layui-inline {
        margin: 0;
    }

    .layui-form-item {
        display: flex;
        margin-bottom: 5px;
    }

    #repairLogList {
       overflow: hidden;
       height: 217px;
    }
    .layuiadmin-card-status li{
        padding:0;
    }
    .layui-form-label-value {
        height: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap; 
        word-break: break-all;
    }
   
</style>

 

        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md6">
                    <div class="layui-card">
                        <div class="layui-card-header">基本信息</div>
                        <div class="layui-card-body" style="padding: 15px;">
                            <form class="layui-form" action="" lay-filter="component-form-group">
                                <input type="hidden" name="id" id="id" value="@Model.Item1.Id" />
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">设备名称：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.Name
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">设备编码：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.DeviceId
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">设备类别：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.DeviceType.Name
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">规格型号：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.Model
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">

                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">是否国产：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item1.IsDomestic == 1)
                                            {
                                                <span>是</span>
                                            }
                                            else
                                            {
                                                <span>否</span>
                                            }
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">固定资产编号：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.No
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">部署位置：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.Room.Name
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">摆放位置：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.Location
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">所属项目：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item1.Project != null)
                                            {
                                                @Model.Item1.Project.Name
                                            }
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">IP地址：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.Ip
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">采购日期：</label>
                                        <label class="layui-form-label layui-form-label-value">

                                            @if (Model.Item1.BuyDate != null)
                                            {@Model.Item1.BuyDate.ToString().Substring(0, 10);
                                        }
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">接管日期：</label>
                                        <label class="layui-form-label layui-form-label-value">

                                            @if (Model.Item1.ReceiveDate != null)
                                            {@Model.Item1.ReceiveDate.ToString().Substring(0, 10);
                                        }
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">供应商：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item1.Supplier != null)
                                            {@Model.Item1.Supplier.Name}
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">在保日期：</label>
                                        <label class="layui-form-label layui-form-label-value">

                                            @if (Model.Item1.ServiceDate != null)
                                            {@Model.Item1.ServiceDate.ToString().Substring(0, 10);
                                        }
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">所属部门：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item1.Depart != null)
                                            {
                                                @Model.Item1.Depart.Name
                                            }
                                        </label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">项目建设部门：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.owner_unit
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">操作系统：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @Model.Item1.Os
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">报废年限：</label>
                                        <label class="layui-form-label layui-form-label-value"></label>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">实际报废时间：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item2 != null && Model.Item2.ScrapDate != null)
                                            {
                                                @Model.Item2.ScrapDate.ToString().Substring(0, 10)
                                            }
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">采购合同：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item1.BuyContract != null)
                                            {@Model.Item1.BuyContract.Title}
                                        </label>
                                    </div>
                              
                                    <div class="layui-inline">
                                        <label class="layui-form-label">维护合同：</label>
                                        <label class="layui-form-label layui-form-label-value">
                                            @if (Model.Item1.ServiceContract != null)
                                            {@Model.Item1.BuyContract.Title}
                                        </label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">运维计划：</label>
                                        <label class="layui-form-label layui-form-label-value"></label>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w80">备注信息：</label>
                                        <textarea style="border: 1px solid #ddd;width:340px;height:60px;resize:none;" readonly>@Model.Item1.Remark</textarea>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="layui-col-md3">
                    <div class="layui-card">
                        <div class="layui-card-header">
                            设备照片
                        </div>
                        <div class="layui-card-body" style="padding-left: 0;padding-right: 0;">
                            <div class="layui-carousel layadmin-carousel layadmin-shortcut" id="imageList" lay-anim="" 
                                 lay-indicator="inside" lay-arrow="none" style="width: 100%; height: 190px !important;">
                                <div carousel-item="" id="imageListItem">
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-card" style="height: 310px;">
                        <div class="layui-card-header">
                            设备二维码
                        </div>
                        <div class="layui-card-body" style="padding:0">
                            <img style="width:100%;margin-top: -10px;" src="/barcode/deviceBarCode?id=@Model.Item1.Id" />
                        </div>
                    </div>
                </div>
                <div class="layui-col-md3">
                    <div class="layui-card" style="height: 253px;">
                        <div class="layui-card-header">
                            相关资料
                        </div>
                        <div class="layui-card-body" style="padding: 15px;">
                            <ul id="fileList" style="padding-left:10px;"></ul>
                        </div>
                    </div>
                    <div class="layui-card" style="height:310px">
                        <div class="layui-card-header">
                            维修记录
                        </div>
                        <div class="layui-card-body" style="padding: 15px;">
                            <ul id="repairLogList" class="layuiadmin-card-status"></ul>
                        </div>
                    </div>
                </div>
               
            </div>
        </div>

<script>

    var $ = layui.$
        , admin = layui.admin
        , element = layui.element
        , layer = layui.layer
        , laydate = layui.laydate
        , table = layui.table
        , upload = layui.upload
        , form = layui.form
        , carousel = layui.carousel
        , laydate = layui.laydate
        , multiSelect = layui.multiSelect;

   

    form.render(null, 'component-form-group');
    laydate.render({
        elem: '#LAY-component-form-group-date'
    });

    layui.config({
        base: '/js/',
    })
    layui.use(['multiSelect'], function () {
        var $ = layui.jquery, form = layui.form, multiSelect = layui.multiSelect;
    });



    //加载图片
    function loadImages() {
        $.ajax({
            url: "/doc/getAllByObjectId?category=1&id=@Model.Item1.Id",
            success: function (d) {

                var data = d.data;
                var html = "";
                for (var i = 0; i < data.length; i++) {
                    if (i == 0) {
                        html += '<div class="layui-row layui-col-space10 layui-this">'
                    } else {
                        html += '<div class="layui-row layui-col-space10 ">'
                    }
                    html += '<img src="/doc/download?id=' + data[i].id + '" />';
                    html += '</div>';
                }
                $('#imageListItem').html(html);

                //渲染幻灯片
                carousel.render({
                    elem: '#imageList'
                    , width: '100%' //设置容器宽度
                    ,height:'190px !important'
                    , arrow: 'always' //始终显示箭头
                });
            }
        });
    }
    loadImages();


    /* 监听提交 */
    form.on('submit(save)', function (data) {
        //开始保存合同信息
        $.post("/DeviceInfo/save", data.field,
            function (e) {
                layer.msg(e.msg);
                if (e.code == 1) { //保存成功
                    window.location.href = "/DeviceInfo/";
                }
            });
        return false;
    });

    //保存并继续添加
    form.on('submit(saveAndAdd)', function (data) {
        //开始保存合同信息
        $.post("/DeviceInfo/save", data.field,
            function (e) {
                layer.msg(e.msg);
                if (e.code == 1) { //保存成功
                    window.location.href = "/DeviceInfo/copy?id=@Model.Item1.Id";
                }
            });
        return false;
    });




      $.ajax({
        url: '/doc/getAllByObjectId?&category=0&id=@Model.Item1.Id',
        success: function (res) {
            var data = res.data;
            for (var i = 0; i < data.length; i++) {
                var log = data[i];
                $('#fileList').append('<li><a class="fileLink" href=" /doc/download?id='+log.id+'">'+log.name+'</a></li>');
            }
            if (data.length == 0) {
                $('#fileList').append("<li><span>暂无数据</span><p></p></li>");
            }
        }
    });

    $.ajax({
        url: '/deviceInfo/repairLog?id=@Model.Item1.Id',
        success: function (res) {
            var data = res.data;
            for (var i = 0; i < data.length; i++) {
                var log = data[i];
                $('#repairLogList').append("<li><span>" + log.beginDate.substring(0, 10)
                    +"</span><p>"+log.remark+"</p>"
                    + "</li>");
            }
            if (data.length == 0) {
                $('#repairLogList').append("<li><span>暂无数据</span><p></p></li>");
            }
        }
    });

    $('.layui-form-label-value').mouseover(function () {
        var text = $(this).text();
        if (this.offsetWidth < this.scrollWidth) {
            layer.tips(text, this);
        }
    });

</script>
